import { UrlPrefixEnum } from '@wlydfe/service'

import http from '@/service'
// 地区数据 API
export interface AreaApiResponse {
  node: string
  name: string
  parentId: string
  level: number // 3: 省, 4: 市, 5: 区
  code: string
  children?: AreaApiResponse[]
  enable?: string
  [key: string]: any
}

// 获取所有地区列表的 API - 一次性返回所有数据
export function getAreaList() {
  return http.post<AreaApiResponse[]>(
    {
      url: '/city/getCityData?parentNode=',
      params: {
        parentNode: '',
      },
    },
    {
      urlPrefix: UrlPrefixEnum.CTP_PORTAL,
    },
  )
}
